package com.zhhs.galaxyott.httpVolley.parser;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.zhhs.galaxyott.beans.MoreSpecialTypeBean;
import com.zhhs.galaxyott.httpVolley.response.MoreSpecialTypeResponse;

public class MoreSpecialTypeParser extends BaseParser<MoreSpecialTypeResponse> {

    @Override
    public MoreSpecialTypeResponse parse(String jsonString) {
        MoreSpecialTypeResponse mResponse = new MoreSpecialTypeResponse();
        try {
            JSONObject mjson = new JSONObject(jsonString);
            if (0 == (mjson.getInt("errCode"))) {
                JSONArray result = mjson.getJSONArray("list");
                for (int i = 0; i < result.length(); i++) {
                    JSONObject jo = result.getJSONObject(i);

                    MoreSpecialTypeBean bean = new MoreSpecialTypeBean();

                    bean.setTypeId(jo.optInt("typeId"));
                    bean.setTypeTitle(jo.optString("typeTitle"));
                    bean.setTypeSort(jo.optInt("typeSort"));

                    mResponse.mMoreSpecialTypeBeans.add(bean);

                }
            }
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return mResponse;
    }
}
